This section is intended to provide a background or context to the invention that is recited in the claims. The description herein may include concepts that could be pursued, but are not necessarily ones that have been previously conceived or pursued. Therefore, unless otherwise indicated herein, what is described in this section is not prior art to the description and claims in this application and is not admitted to be prior art by inclusion in this section.
JAVA™ is an object-oriented programming language and platform that was originally developed in the early 1990s. JAVA™ components can invoke native platform application programming interfaces (APIs) by using a standard native code embedding mechanism, commonly referred to as a JAVA™ Native Interface (JNI™) The JNI™ is primarily intended to foster native API reuse or to implement mission-critical parts of the code in a native language for improved efficiency. The JNI™ approach is quite helpful for the reuse of existing APIs from JAVA™. The JNI™ allows a component written in the JAVA™ language to call code written in any other programming language by declaring one or more native JAVA™ methods, implementing a native library containing one or more functions that implement the native JAVA™ methods in a different programming language, loading the library that contains the native code, and then calling the native method.
The static footprint of a JNI™-based mixed-language JAVA™ class comprises two primary contributions, namely the JAVA™ class (bytecode) footprint and the additional native code footprint. Native code comprises the method's business logic implementation and additional JNI™-specific boilerplate code (e.g., for marshalling/un-marshalling I/O parameters between JAVA™ and native side, to create new JAVA™ objects and/or to invoke methods on a JAVA™ object from native code). Invoking native objects from JAVA™ via JNI™ requires the addition of more JAVA™-side and native-side boilerplate code in order to deal with a native object's lifecycle (i.e., invocation of a native object constructors, methods, and destructors) since JNI™ relies on a procedural programming model. Thus, object-oriented concepts must be implemented from scratch on top of the functional JNI™ programming model.
When using JNI™ to implement JAVA™ system components and APIs, developers must find a satisfactory trade-off between a pair of conflicting requirements. The first such requirement is to provide a minimum functionality-gap, meaning that most of the native APIs available to native developers should be available to JAVA™ components as well. The second requirement is for a minimum JAVA™ component static footprint. In other words, adding new JAVA™ APIs to a certain JAVA™ runtime should not have a strong impact on the overall JAVA™ runtime static footprint in terms of both native and JAVA™ libraries to be added. This requirement is very important when deploying and running JAVA™ platforms on embedded and mobile devices which often possess relatively low memory and processing capabilities.
Unfortunately, the above two requirements conflict with each other, as minimizing the functionality-gap by using JNI™ can cause the final static footprint of a JAVA™ component to increase significantly. This is commonly referred to as footprint explosion. In fact, the one-to-one relationship between native JAVA™ methods and functions in the native implementation makes the amount of native code used to implement native JAVA™ methods increase when the number of JAVA™ native methods to implement increases. Even if native boilerplate code can be reused by wrapping frequently used libraries in a JAVA™ API, as depicted in FIG. 1, it is still difficult to avoid footprint explosion since the more native functions are wrapped, the larger the size of the additional JNI™ code. This conflict is even more difficult to solve when dealing with object-oriented native APIs due to the existing programming model mismatch between the JNI™ C primitives and the C++ object-oriented programming model.
A number of proposals have been made to enable JAVA™ wrapping of native C++ objects. These proposals are discussed, for example, in the Simplified Wrapper and Interface Generator (SWIG) User's Manual 1.1, (available at the SWIG website); U.S. Pat. No. 6,066,181, issued May 23, 2000; and U.S. Patent Publication No. 2005/0044540, published Feb. 24, 2005. These documents discuss a pair of strategies for the JAVA™ wrapping. However, the processes discussed in these documents do not allow for the minimizing of the static footprint, as they require one new native library for each class/function to be integrated. Therefore, the minimizing of the functionality gap with these systems can easily lead to footprint explosion since all boilerplate code cannot be re-used.
In addition to the above, MICROSOFT® Corporation's C# Programmer's Reference: Platform Invoke Tutorial (available at the MSDN: Microsoft Development website), while somewhat useful, is strictly limited to the invocation of native procedural APIs and not for the invocation of object-oriented APIs.
There is therefore a need for a system and method of reducing the functionality gap between JAVA™ and native platform, while at the same time providing only a minimum impact on the static footprint of the JAVA™ environment.